//
//  MessageCell.m
//  TengyunStation
//
//  Created by Johnny on 15/9/16.
//  Copyright (c) 2015年 xingrong. All rights reserved.
//

#import "MessageCell.h"
#import "Singleton.h"

@implementation MessageCell

- (void)awakeFromNib {
    // Initialization code
    _messageImageView.layer.cornerRadius = 4;
    _numberLabel.layer.cornerRadius = 8;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)reloadMessageCell:(Message *)message {
    if ([message.mesasgeType isEqualToString:@"00"]) {
        _messageImageView.image = [UIImage imageNamed:@"message_xitong"];
        _titleLabel.text = @"系统消息";
        if ([Singleton shareInstance].statisticsCount.systemMessageCount > 0) {
            _numberLabel.hidden = NO;
            _numberLabel.text = [NSString stringWithFormat:@"%d",[Singleton shareInstance].statisticsCount.systemMessageCount];
        } else {
            _numberLabel.hidden = YES;
        }
    } else if ([message.mesasgeType isEqualToString:@"01"]) {
        _messageImageView.image = [UIImage imageNamed:@"message_yewu"];
        _titleLabel.text = @"业务消息";
        if ([Singleton shareInstance].statisticsCount.businessMessageCount > 0) {
            _numberLabel.hidden = NO;
            _numberLabel.text = [NSString stringWithFormat:@"%d",[Singleton shareInstance].statisticsCount.businessMessageCount];
        } else {
            _numberLabel.hidden = YES;
        }
    } else if ([message.mesasgeType isEqualToString:@"02"]) {
        _messageImageView.image = [UIImage imageNamed:@"message_person"];
        _titleLabel.text = @"个人消息";
        if ([Singleton shareInstance].statisticsCount.personalMessageCount > 0) {
            _numberLabel.hidden = NO;
            _numberLabel.text = [NSString stringWithFormat:@"%d",[Singleton shareInstance].statisticsCount.personalMessageCount];
        } else {
            _numberLabel.hidden = YES;
        }
    } else if ([message.mesasgeType isEqualToString:@"04"]) {
        _messageImageView.image = [UIImage imageNamed:@"notice_icon_dais"];
        _titleLabel.text = @"快递接收";
        if ([Singleton shareInstance].statisticsCount.receiveMessageCount > 0) {
            _numberLabel.hidden = NO;
            _numberLabel.text = [NSString stringWithFormat:@"%d",[Singleton shareInstance].statisticsCount.receiveMessageCount];
        } else {
            _numberLabel.hidden = YES;
        }
    }
    _contentLabel.text = message.content;
    _timeLabel.text = message.showDay;
}

@end
